
#ifndef  BUF_H
#define  BUF_H

#include "types.h"
#include "fs.h"
#include "sleeplock.h"

struct buf {
  int valid;
  int disk;     //does disk "own" buf?
  uint blockno;
  uint dev;
  
  struct sleeplock  lock; 
  uint refcnt;
  struct buf * prev;
  struct buf * next;
  unsigned char data[BSIZE];
};

void buf_init(struct buf * b, struct buf * prev, struct buf * next);
void buf_init_zero_data(struct  buf * b, uint blockno);
void buf_set_char(struct buf * b, uchar c);

void buf_print(struct buf * b);

#endif   /* BUF_H */
